﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Toulr.Util.Ioc;
using Toulr.Services;
using Toulr.Domains.System;
using System.Text;

public partial class WebUI_Shop_AddShop : CommPageBase
{
    /// <summary>
    /// Gets or sets the state of the current page.
    /// </summary>
    /// <value>The state of the current page.</value>
    /// <Author>Tecky Lee</Author>
    /// <Date>2011/6/19 15:54</Date>
    EditPageOprType CurrentPageState
    {
        get
        {
            if (ViewState["PageOprType"] == null)
            {
                ViewState["PageOprType"] = EditPageOprType.Add;
            }
            return (EditPageOprType)ViewState["PageOprType"];
        }
        set { ViewState["PageOprType"] = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            if (CurrentPageState == EditPageOprType.Modify)
            {
                //修改状态

            }
            else
            {
                ddlShopCategories.Items.Add(new ListItem("--请选择商店类型--", "-1"));
                ICommonService commService = UnityHelper.GetInstance<ICommonService>();
                IList<InfoCategories> catgList = commService.GetInfoCategoriesRoot().Result;
                foreach (var item in catgList)
                {
                    ddlShopCategories.Items.Add(new ListItem(item.CategoryName, item.Id.ToString()));
                }

                ddlShopCategories.SelectedIndex = 0;
            }
        }
    }

    /// <summary>
    /// Gets the child category.
    /// </summary>
    /// <param name="categoryId">The category id.</param>
    /// <returns></returns>
    /// <Author>Tecky Lee</Author>
    /// <Date>2011/6/19 15:54</Date>
    [AjaxPro.AjaxMethod]
    public InfoCategories[] GetChildCategory(int categoryId)
    {
        ICommonService commService = UnityHelper.GetInstance<ICommonService>();
        IList<InfoCategories> childs = commService.GetInfoCategoriesByPid(categoryId).Result;
        return childs.ToArray();
    }

    /// <summary>
    /// Gets the extensive properties.
    /// </summary>
    /// <param name="categoryId">The category id.</param>
    /// <returns></returns>
    /// <Author>Tecky Lee</Author>
    /// <Date>2011/6/19 15:54</Date>
    [AjaxPro.AjaxMethod]
    public InfoCategoriesProperty[] GetExtensiveProperties(int categoryId)
    {
        IShopService shopService = UnityHelper.GetInstance<IShopService>();
        IList<InfoCategoriesProperty> properties = shopService.GetOptionalPropertys(categoryId).Result;
        return properties.ToArray();
    }
}